As semiconductor devices contain more and more permanent data storage elements the probability of failure occurring in the semiconductor device due to wrongly programmed data storage elements increases. It is necessary for such a semiconductor device to have an error correction mechanism to enhance the reliability and the data integrity of the semiconductor device.